package com.lhn.aop;

import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author lhn
 * @date 2024-08-22 18:06
 */
@Component
@Aspect
public class MyAdvice {

    @Pointcut("execution(* com.lhn.service.impl.ResourceServiceImpl.openUrl(..))")
    public void pc(){}

    @Around("pc()")
    public Object around(org.aspectj.lang.ProceedingJoinPoint pjp) throws Throwable {
        Object[] args = pjp.getArgs();
        for (int i = 0; i < args.length; i++) {
            if (
                    args[i] instanceof String

            ) {
                args[i] = args[i].toString().trim();
            }
        }
        Object o = pjp.proceed(args);
        return o;
    }
}
